interface DateRollType {
  toggleShow(): void;
}

const useSelYr = defineStore("selYr", () => {
  const yearRange = ref<(number | string)[]>([]);
  const startRef = ref<DateRollType>();
  const endRef = ref<DateRollType>();
  function initYear(newYrRange: (number | string)[] = []) {
    // console.log(newYrRange);
    yearRange.value = newYrRange;
  }
  const toggleYear = (type: "start" | "end") => {
    // console.log(yearRange.value);
    const target = type === "start" ? startRef : endRef;
    if (target.value) {
      target.value.toggleShow();
    } else {
      console.warn(`${type}Ref is not initialized or is null.`);
    }
  };

  return {
    toggleYear,
    initYear,
    yearRange,
    startRef,
    endRef
  };
});
export const useSelYrRefs = () => storeToRefs(useSelYr());
export default useSelYr;
